package com.banshuibao.bsb_android.adapter;

import android.content.Context;
import android.text.TextUtils;
import android.widget.ImageView;
import android.widget.TextView;

import com.banshuibao.bsb_android.R;
import com.banshuibao.bsb_android.model.PersonPageModelTwo;
import com.banshuibao.bsb_android.util.ImageUtil;
import com.banshuibao.bsb_android.util.TimeUtil;

import java.util.List;

/**
 * Created by Administrator on 2017/12/19.
 */

public class PersonalPageAdapter1 extends MineBaseAdapter<PersonPageModelTwo.DataBean> {

    private Context context;

    public PersonalPageAdapter1(Context context, List<PersonPageModelTwo.DataBean> data, int layoutResId) {
        super(context, data, layoutResId);
        this.context = context;
    }

    @Override
    protected void bindData(ViewHolder holder, PersonPageModelTwo.DataBean item) {
        TextView content = (TextView) holder.getView(R.id.personal_item_title);
        ImageView head = (ImageView) holder.getView(R.id.personal_item_head);
        TextView name = (TextView) holder.getView(R.id.personal_item_name);
        TextView position = (TextView) holder.getView(R.id.personal_item_compony);
        TextView date = (TextView) holder.getView(R.id.personal_item_time);
        TextView money = (TextView) holder.getView(R.id.personal_item_listen);
        if (item != null) {
            String question = item.getQuestion();
            String headImg = item.getHeadImg();
            String name1 = item.getName();
            String positiotn = item.getPositiotn();
            double quPrice = item.getQuPrice();
            long createDate = item.getCreateDate();
//            LogUtil.e(quPrice);
            if (!TextUtils.isEmpty(question)) {
                content.setText(question);
            }
            if (!TextUtils.isEmpty(name1)) {
                name.setText(name1);
            }
            if (!TextUtils.isEmpty(positiotn)) {
                position.setText(positiotn);
            }
            if (quPrice != 0) {
                money.setText(quPrice + "元");
            } else {
                money.setText("限时免费听");
            }
            if (!TextUtils.isEmpty(headImg)) {
                ImageUtil.loadImageHead(context, headImg, head);
            }
            String time = null;
            if (createDate != 0) {
                time = TimeUtil.format(createDate);
            } else {
                time = "";
            }
            date.setText(time);
        }
    }
}
